﻿
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 晨曦超市管理系统.员工管理
{
    public partial class YuanAdd1 : Form
    {
        public YuanAdd1()
        {
            InitializeComponent();
        }

        private void YuanAdd_Load(object sender, EventArgs e)
        {
            radioButton1.Checked = true;
            comboPosition.Items.Add("管理员");
            comboPosition.Items.Add("收银员");
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string Sex = "男";
                string Name = this.textName.Text.Trim();
                string Nativeplace= this.textNativeplace.Text.Trim();
                if (radioButton1.Checked)
                {
                    Sex = "男";
                }
                if (radioButton2.Checked)
                {
                    Sex = "女";
                }
                string IDcard = this.textID.Text.Trim();
                string HireDate = dateTimePicker1.Value.ToString();
                string ContactAddress = this.textAddress.Text.Trim();
                string ContactNusmber = this.textPhone.Text.Trim();
                string Salary = this.textSalary.Text.Trim();
                string Age = this.textAge.Text.Trim();
                string UserNameID = this.textNameID.Text.Trim();
                string Password = this.textPwd.Text.Trim();

                string Position = comboPosition.Text;
                string Commission = textCommission.Text.Trim();
                string Remark = textRemark.Text.Trim();

                string sqlstr = "insert  informationOfEmployees(Name,JiGuan,Sex,IDcard,HireDate,ContactAddress,ContactNusmber,Salary,NianLing,UserNameID,Paw,Position,TiChen,Remark) values('" + Name + "','" + Nativeplace + "','" + Sex + "','" + IDcard + "','" + HireDate + "','" + ContactAddress + "','" + ContactNusmber + "'," + Salary + "," + Age + "," + UserNameID + ",'" + Password + "','" + Position + "'," + Commission + ",'" + Remark + "')";
                bool duicuo = DBHelper.QEX(sqlstr);
                if (duicuo)
                {
                    MessageBox.Show("添加成功");
                    radioButton1.Checked = true;
                    this.textName.Text = "";
                    this.textNativeplace.Text = "";
                    this.textID.Text = "";
                    this.textAddress.Text = "";
                    this.textPhone.Text = "";
                    this.textSalary.Text = "";
                    this.textAge.Text = "";
                    this.textNameID.Text = "";
                    this.textPwd.Text = "";
                    this.textCommission.Text = "";
                    this.textRemark.Text = "";
                    comboPosition.SelectedIndex = 0;
                }
                else
                {
                    MessageBox.Show("添加失败");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this,"添加不成功请联系管理员原因："+ex.Message);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void label13_Click(object sender, EventArgs e)
        {

        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void checkBox2_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void textnumber_TextChanged(object sender, EventArgs e)
        {

        }
    }
}
